package com.gidgabs.modules.api.controller.discovery;

import com.gidgabs.common.annotation.LoginUserApi;
import com.gidgabs.common.utils.ReturnJson;
import com.gidgabs.common.validator.Assert;
import com.gidgabs.dto.TbUserDto;
import com.gidgabs.dto.TbUserJournalDto;
import com.gidgabs.modules.api.service.discovery.DiscoveryJournalService;
import com.gidgabs.modules.api.service.discovery.DiscoveryUserService;
import com.gidgabs.modules.entity.TbUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by tby on 2018/6/29.
 */
@Api("发现模块日志相关")
@RestController
@RequestMapping("api/discovery")
public class ApiDiscoveryJournalController {

    @Autowired private DiscoveryJournalService discoveryJournalService;

    @ApiOperation(value = "获取用户的发表的日志,按照日期倒序排列")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageSize",value = "页面大小",dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "pageNo",value = "页码",dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "uerId",value = "用户id",dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "token",value = "token",dataType = "string",paramType = "header")
    })
    @RequestMapping(value = "journal/list", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"})
    public ReturnJson<TbUserJournalDto> queryList(Integer pageSize, Integer pageNo, Integer uerId) {
        if (pageNo==null){
            pageNo=1;
        }if (pageSize==null){
            pageSize=10;
        }
        Assert.isNull(uerId,"userId参数不能未空");
        return discoveryJournalService.queryList(pageSize,pageNo,uerId);
    }




}
